home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 1 Issue 2 / PDCD-1 - Issue 02.iso / _utilities / utilities / 003 / _drlink / Drlink_doc < prev    next >
Text File  |  1993-08-28  |  36KB  |  837 lines

  1.                      The 'Drlink' AOF Linker
  2.                      ~~~~~~~~~~~~~~~~~~~~~~~
  3.  
  4. Disclaimer
  5. ~~~~~~~~~~
  6. The 'Drlink' linker is provided 'as is' and people using it do so
  7. entirely at their own risk. No liability whatsoever will be
  8. accepted for any loss or damage arising from the use of this
  9. software.
  10.  
  11.  
  12. Introduction
  13. ~~~~~~~~~~~~
  14. Drlink is a linker that is intended to be a partial substitute for
  15. the Acorn linker, 'link'. It is aimed at people with compilers
  16. that generate object files in Acorn's AOF format but who do not
  17. have a copy of 'link', for example, people who want to use the DDE
  18. Pascal compiler or TLA or perhaps their own homebrew compilers.
  19. Drlink accepts object files in Acorn's AOF format and libraries
  20. in Acorn's ALF format and links them to produce an executable
  21. image in either Acorn's AIF format or a plain binary image. It can
  22. also be used to link relocatable modules. Drlink is modelled
  23. very closely on the version of 'link' that comes with release 3 of
  24. Acorn's C compiler but it is not really a complete replacement for
  25. it as it does not have the same range of facilities. What is
  26. there, it is hoped, should be adequate in most cases. Drlink is
  27. designed to link 'ordinary' programs and cannot do some of the
  28. fancy things link can such as create partially-linked AOF files.
  29. Of course, some of these features could be added at a later date
  30. but the current version of Drlink, 0.24, does not support them.
  31. On the other hand, it does contain some features found on later
  32. releases of 'link' and other AOF linkers, such as the ability to
  33. increase the size of the wimpslot if necessary when running in a
  34. task window and support for extended command lines. Other features
  35. include the ability to scan libraries more than once when
  36. resolving symbols and, assuming the right compiler options have
  37. been used when compiling programs, being able to leave out unused
  38. functions from executable images. Hopefully features like these
  39. will make the linker attractive to people who use link as well.
  40.  
  41.  
  42. Thanks...
  43. ~~~~~~~~~
  44. I would like to thank the people on Arcade who tested Drlink for
  45. me and made many helpful and useful suggestions, and, in
  46. particular, Simon Glass for his help with some parts of the code
  47. and for suggesting changes and improvements.
  48.  
  49.  
  50. Using Drlink
  51. ~~~~~~~~~~~~
  52. Drlink is a command line-based program and has the same command
  53. syntax as 'link'. It can be used in the same environments as
  54. 'link', for example, with amu. If it is renamed as 'link', then
  55. it can be dynamically invoked from either the Acorn C or DDE
  56. Pascal compilers as well. It accepts the same options as 'link',
  57. although a number of them are unsupported and will be flagged as
  58. errors. Drlink also supports extended command lines. (Further
  59. information on this can be found in the section 'Extended Command
  60. Line Support' below.)
  61.  
  62. The command syntax is:
  63.  
  64.     drlink <list of files> <options>
  65.  
  66. where:
  67.  
  68. <list of files> is the list of object files and libraries to be
  69.                 included in the linked program.
  70.  
  71. <options>       is the options to be used when linking the
  72.                 program.
  73.  
  74. Options and object file names can be freely intermixed. The linker
  75. processes all the options before moving on to the link itself.
  76.  
  77. Filenames
  78. Each filename in the list of object files should be fully
  79. qualified, that is, Drlink makes no assumptions as to where the
  80. object files are to be found. Wildcards are permitted, in which
  81. case Drlink loads all the files that match the wildcard. If the
  82. directory containing the object files is called 'o', then Drlink
  83. will also accept 'back-to-front' filenames, for example, 'sieve.o'
  84. instead of 'o.sieve'. If a path is used as part of a filename, for
  85. example, 'C:', the way Drlink treats the filename depends on
  86. whether it contains wildcards or not. If it does not, then every
  87. directory on the path will be searched to find the file until
  88. either the file is found or the end of the list is reached. On the
  89. other hand, if the filename contains wildcards, only the first
  90. directory listed on the path will be checked. (This is how link
  91. behaves.) Examples:
  92.  
  93.     o.sieve
  94.     o.dhry1 o.dhry2 c:o.stubs
  95.     o.dhry* c:o.ansilib
  96.     dhry*.o c:ansilib.o
  97.     o.* c:o.*
  98.     O.world scsi::Arc.$.programs.!Pascal.O.Plib C:O.stubs
  99.  
  100. Drlink ignores the case of object file and library names.
  101.  
  102. Options
  103. As noted above, Drlink recognises the same options as 'link',
  104. even if it does flag a number as unsupported, plus has one or two
  105. of its own. Options take the form of a '-' followed by the option
  106. name. Some options are followed by an argument. One or more blanks
  107. should be left between the option name and the argument. The case
  108. of the option and any argument is ignored. Options that are
  109. supported are:
  110.  
  111.     -aif       Create an AIF image file.
  112.  
  113.                This is the standard format for programs running
  114.                under RISCOS where a small header is attached to
  115.                the start of the program containing various bits
  116.                and pieces of information.
  117.  
  118.     -bin       Create a plain binary image file.
  119.  
  120.                A binary image file does not have the header that
  121.                AIF files have on them and consist of nothing but
  122.                the linked program. This has two consequences.
  123.                Firstly, and most importantly, zero-initialised
  124.                data areas will not be cleared to zeros when the
  125.                program starts running as the routine to do this is
  126.                part of the AIF header. Secondly, if debugging
  127.                tables are included in the executable image, there
  128.                is nothing to indicate where they are.
  129.  
  130.     -case      Ignore the case of symbols when trying to resolve
  131.                symbol references. If this option is omitted, then
  132.                the case of the letters in symbol names is treated
  133.                as significant.
  134.  
  135.     -debug     Include debugging information in the image file. If
  136.                this option is omitted, any debugging tables
  137.                generated by the compiler that produced the AOF
  138.                file will be left out of the final image file. If
  139.                it is specified then any debugging tables found
  140.                will be included, along with some low-level tables
  141.                the linker itself creates. In the case where the
  142.                AOF files to be linked do not contain debugging
  143.                tables, only the linker's low-level tables will be
  144.                included.
  145.  
  146.                There is a second debug option, '-keepdebug', that
  147.                can be used to selectively include debugging
  148.                tables. Only one of '-keepdebug' or '-debug' should
  149.                be used. If both options are used, '-debug' takes
  150.                precedence.
  151.  
  152.                Note that if this option and '-bin' is used then
  153.                the debugging tables will still be included
  154.                although they will not really be of much use as
  155.                debuggers such as 'asd' would not be able to find
  156.                them. On the other hand, a routine in the program
  157.                might be able to locate them and for this reason
  158.                they are still included in the image file.
  159.  
  160.     -edit <name>
  161.                Gives the name of a file from which 'link edit'
  162.                commands are to be taken. For more information,
  163.                refer to the section 'Link Edit Commands' below.
  164.  
  165.     -help      Print a summary of Drlink options.
  166.  
  167.     -map       Print a list of areas (read-only code, data,
  168.                debugging tables, etc) in the image file giving
  169.                their addresses, sizes and types and the name of
  170.                the original AOF files that contained the areas.
  171.  
  172.     -module    Create a relocatable module in RMF format.
  173.  
  174.     -output <name>
  175.                Write the executable image file to file <name>. If
  176.                this option is omitted, the program is written to
  177.                the file '!Runimage' in the current directory.
  178.  
  179.     -relocatable
  180.                Create a reloctable AIF image file.
  181.  
  182.     -rmf       Create a reloctable module in RMF format.
  183.  
  184.     -verbose   Print messages as the link progresses saying how
  185.                far it has got. Some extra warning messages are
  186.                also produced if the linker finds aspects of the
  187.                link that look a bit iffy, for example, it will
  188.                print warning messages about unresolved 'weak'
  189.                external references. Normally, the linker keeps
  190.                quiet about such things.
  191.  
  192.     -via <name>
  193.                According to the documentation on 'link', this
  194.                option allows the list of files to be included in
  195.                the link to be specified in file <name>. In fact,
  196.                the file can also contain link options and this is
  197.                how the option '-via' has been implemented in
  198.                Drlink. When this option is encountered, input is
  199.                switched to the file <name> and the list of files
  200.                and options taken from that file until end-of-file
  201.                is reached whereupon input reverts back to the
  202.                command line. The only option that is not valid in
  203.                a '-via' file is '-via'. This option can be used
  204.                as many times as is necessary on the command line.
  205.                The format of the filenames and options in the file
  206.                <name> is exactly the same as when specified on the
  207.                command line, except they can be spread over as
  208.                many lines in the file as necessary. Any 'newline'
  209.                characters in the file are treated as if they were
  210.                blanks.
  211.  
  212.     -workspace <size>
  213.                For a relocatable AIF image file, reserve <size>
  214.                bytes of memory after the image when relocating
  215.                it. <size> is rounded up to a whole number of
  216.                words. <size> is taken to be decimal by default
  217.                but can be prefixed by '&' or '0x' to give a
  218.                hexadecimal value. It can be postfixed by 'k' or
  219.                'm' to indicate the size is in kilobytes or
  220.                megabytes. The case of the 'k', 'm', 'x' or any of
  221.                the hex digits 'a' to 'f' is ignored.
  222.  
  223. All other 'link' options are recognised but are unsupported. They
  224. are: aof, base, dbug, entry, overlay and xref.
  225.  
  226. The linker has the following extra options of its own:
  227.  
  228.     -debimage  If this option is specified and the image file to
  229.                be written contains debugging tables, the filetype
  230.                of the image file is set to 'DebImage' instead of
  231.                'Absolute'. If this option is not used, the
  232.                filetype of the image file is always set to
  233.                'Absolute'.
  234.  
  235.     -keepdebug <file list>
  236.                The purpose of this option is to allow debugging
  237.                information to be included selectively in the image
  238.                file. <file list> is a list of the object files and
  239.                library members where any compiler generated
  240.                debugging tables found are to be kept. Debugging
  241.                tables in any other files or members are ignored.
  242.                Any linker-generated low-level debugging tables
  243.                will only include entries for the files in <file
  244.                list>.
  245.  
  246.                The format of <file list> is a string of names of
  247.                files and library members separated by commas with
  248.                no other intervening characters or a string of
  249.                names enclosed in double quotes separated by one or
  250.                more blanks. The names should exactly match the
  251.                names of the files or library members to which they
  252.                refer, although the case of the names is ignored.
  253.                Wildcarded names are not permitted, although the
  254.                case where a name in <file list> matches a file
  255.                name in the list of files to link that resulted
  256.                from expanding a wildcarded name is allowed.
  257.  
  258.                Only one of the debugging options should be used at
  259.                a time. If both are found on the command line then
  260.                '-debug' takes precedence over '-keepdebug' and the
  261.                image file will contain all the debugging tables
  262.                the linker finds.
  263.  
  264.     -lib <library list>
  265.                <library list> is a list of libraries that Drlink
  266.                will search when attempting to resolve symbol
  267.                references. The list can take two forms. Either it
  268.                can supplied as a string of library names separated
  269.                by commas with no intervening blanks or any other
  270.                white space characters or the list can be enclosed
  271.                in double quotes with the names separated by one
  272.                or more blanks. Wildcarded library names are not
  273.                permitted.
  274.  
  275.                This option should not be needed in the normal
  276.                course of events. Drlink can tell the difference
  277.                between AOF files and libraries without having to
  278.                be told which is which but this is not the purpose
  279.                of the option. Its purpose is to reduce the
  280.                amount of memory used by the linker. The way the
  281.                Drlink works is to read *all* the files given on
  282.                the  command line into memory including any
  283.                libraries. Whilst this speeds up pulling members
  284.                out of the libraries, it can be quite expensive in
  285.                terms of memory. Libraries specified after '-lib'
  286.                will not be brought into memory and members will
  287.                be loaded from them as required.
  288.  
  289.     -nounused  This option is used to control whether unreferenced
  290.                areas in the image file will be left out. By
  291.                default, all areas are left in but if '-nounused'
  292.                is specified, the linker checks each area in the
  293.                executable image and leaves out any that it finds
  294.                are not referenced by any other areas.
  295.  
  296.                The purpose of this option is basically to strip
  297.                out any unused functions in a program. To achieve
  298.                this, it is necessary first to compile the program
  299.                with the '-zo' C (and DDE Pascal) compiler option.
  300.                This has the effect of spliting each function up
  301.                into its own self-contained 'area' in the object
  302.                code file. If '-nounused' is specified, the linker
  303.                examines all the areas and discards any that it
  304.                finds are not referenced from any other areas. In
  305.                fact, if the linker finds that, as a result of
  306.                throwing away an area, others that it referenced
  307.                now become unused, it will discard those other
  308.                areas as well. Unfortunately, it will not detect
  309.                cases where there are loops, that it, if area 'a'
  310.                calls only area 'b' and area 'b' calls only area
  311.                'a', it will not detect that it is safe to throw
  312.                away both areas. On the other hand, it can handle
  313.                the case where an otherwise unused area calls only
  314.                itself.
  315.  
  316.                Note that if the '-verbose' option is used, Drlink
  317.                will print a list of areas that have been left out
  318.                of the image file, along with the name of the first
  319.                symbol in the area if it can find one. This should
  320.                hopefully be the name of the function contained in
  321.                that area in an AOF file produced by the C
  322.                compiler.
  323.  
  324.                This option is not present in the C release 3
  325.                linker but it might be available in other AOF
  326.                linkers.
  327.  
  328.     -rescan    This tells the linker to scan libraries more than
  329.                once if necessary when searching for symbols.
  330.                'link' scans them only once so it is important to
  331.                specify libraries in the correct order. Drlink also
  332.                works like this unless '-rescan' is used, in which
  333.                case it will continue searching the libraries in
  334.                the order in which they were specified on the
  335.                command line until all symbols have been found or
  336.                all libraries have been checked for a particular
  337.                symbol.
  338.  
  339.                This option is not present in the C release 3
  340.                linker but it might be available in other AOF
  341.                linkers.
  342.  
  343.     -symbols <file>
  344.                Create a file listing all the relocatable symbols
  345.                in the image file. They are listed in address
  346.                order.
  347.  
  348.  Note that most options can be abbreviated to one or two letters.
  349. The minimum abbreviation for each option is:
  350.  
  351.     -aif         -ai
  352.     -bin         -bi
  353.     -case        -c
  354.     -debimage    -debi
  355.     -debug       -d
  356.     -edit        -e
  357.     -help        -h
  358.     -keepdebug   -keep
  359.     -lib         -lib
  360.     -map         -map
  361.     -module      -m
  362.     -nounused    -no
  363.     -output      -o
  364.     -relocatable -r
  365.     -rescan      -res
  366.     -rmf         -rm
  367.     -symbols     -s
  368.     -verbose     -v
  369.     -via         -via
  370.     -workspace   -w
  371.  
  372. Examples:
  373.  
  374.     drlink o.sieve c:o.stubs
  375.     drlink sieve.o c:stubs.o
  376.     drlink o.dhry1 o.dhry2 c:o.ansilib
  377.     drlink o.dhry1 o.dhry2 c:o.stubs -o dhry
  378.     drlink o.* -no -o PDC
  379.     drlink o.life c:o.risc_oslib c:o.stubs -map -v
  380.     drlink o.life -lib c:o.risc_oslib,c:o.ansilib
  381.     drlink o.life -lib "c:o.risc_oslib  c:o.ansilib"
  382.     drlink o.balls64 p:o.plib c:o.risc_oslib P:O.Stubs
  383.     drlink o.balls64 -via pasclibs -map -v
  384.  
  385. The default options are to generate an AIF image file, to treat
  386. the case of symbols names as significant, not to include debugging
  387. information, to include all areas in the image file, not to
  388. produce an area map or symbol listing and to keep quiet about what
  389. the linker is doing.
  390.  
  391. In normal use, it should not really be necessary to use any of the
  392. linker options and running Drlink should just be a case of
  393. typing the command and the list of files and libraries to include
  394. in the linked image file, perhaps using the '-d' option to include
  395. debugging tables or '-o' to change the name of the linked image
  396. file. 
  397.  
  398.  
  399. Return Codes
  400. ~~~~~~~~~~~~
  401. If a link works, Drlink gives a return code of zero. If it fails,
  402. it posts a return code of twelve. A fatal error produces a return
  403. code of sixteen.
  404.  
  405.  
  406. Extended Command Line Support
  407. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  408. Drlink can make use of the extended command line facility that
  409. is provided by the 'DDEUtils' module. This allows the command line
  410. passed to Drlink to be of any length and not restricted to the
  411. normal limit of 255 characters. If the linker finds there is an
  412. extended command line available, it uses that in preference to the
  413. standard command line, which it completely ignores.
  414.  
  415. In order to use this facility, it is necessary to have the module
  416. 'DDEUtils' loaded and to use software that can set up extended
  417. command lines, for example, amu. 
  418.  
  419.  
  420. Link Edit Commands
  421. ~~~~~~~~~~~~~~~~~~
  422. This is a feature that allows symbols in the AOF files to be
  423. edited in various ways. Four operations are possible:
  424.  
  425. 1.  Rename a symbol in an AOF file.
  426. 2.  Change a symbol reference in an AOF file.
  427. 3.  Hide a symbol in an AOF file by making it 'local'.
  428. 4.  Reveal a symbol in an AOF file by making it 'global'.
  429.  
  430. The purpose of these commands is to resolve problems where
  431. different AOF files define symbols with the same name or to enable
  432. what would be unresolved symbol references to be replaced with
  433. references to defined symbols. Note that all that the commands do
  434. is act as a filter on the AOF files before they are passed to the
  435. main link routines and that if, for example, a symbol reference is
  436. changed, then there are no checks to make sure that the new symbol
  437. refers to the same sort of 'thing' as the old.
  438.  
  439. The commands are read from the file specified on the option
  440. '-edit'. Note that, unlike 'link', multiple 'link edit' files
  441. can be supplied. The general format of the commands is:
  442.  
  443.     <command> <filename> ( <one or two symbol names> )
  444.  
  445. <command> is one of the four commands described below and <filename>
  446. is the name of the AOF file or library member that will be
  447. affected by the command. Depending on the command, either one or
  448. two symbol names follows in brackets. The commands are free-form
  449. and can be spread over as many lines as necessary in the file.
  450. Several commands can be stacked on one line and there is no limit
  451. on the number of commands in a file.  At least one space should be
  452. left between the command and the filename but they are optional
  453. after that. The case of the link edit commands themselves is
  454. ignored as is that of any file names, but the case of symbol names
  455. is taken as significant, unless the option '-case' is specified on
  456. the command line as well in which case it is ignored. It is
  457. possible for several commands to refer to the same symbol, so
  458. that, for example, the name of a symbol could be changed in one
  459. file and references to it in another file could also be changed to
  460. that name as well. The order of the commands in the file is, in
  461. general, unimportant, but also refer to the note below. If, on the
  462. other hand, a symbol is to be renamed and its scope changed at the
  463. same time, then both edit commands should refer to the symbol by
  464. the symbol's old name.
  465.  
  466.  
  467. Rename a Symbol
  468. The format of the command is:
  469.  
  470.     rename <filename> ( <old name> , <new name> )
  471.  
  472. The effect of the command is to rename the symbol <old name>
  473. defined in file <filename> as <new name>. All references to the
  474. symbol should use <newname>.
  475.  
  476.  
  477. Change a Symbol Reference
  478. The format of this command is:
  479.  
  480.     change <filename> ( <old name> , <new name> )
  481.  
  482. It changes external references to symbol <old name> in file
  483. <filename> to <new name>.
  484.  
  485. Hide a Symbol
  486. This command's format is:
  487.  
  488.     hide <filename> ( <symbol name> )
  489.  
  490. If the symbol <symbol name> in file <filename> is marked as being
  491. visible to any file that references it, its scope is change to
  492. 'local' so that it can only be referenced in the file in which it
  493. was declared.
  494.  
  495. Reveal a Symbol
  496. This command has the format:
  497.  
  498.     reveal <filename> ( <symbol name> )
  499.  
  500. If the symbol <symbol name> in file <filename> is marked as a
  501. 'local' symbol, that is, can only be referenced in the file file
  502. in which it was declared, its scope is changed to 'global' so that
  503. any file can reference it.
  504.  
  505. Examples:
  506.  
  507.     hide o.sieve(main)
  508.  
  509.     rename o.miscprocs(isalnum,isalfanum)
  510.     change o.lexicals(isalnum,isalfanum)
  511.     change o.preproc(isalnum,isalfanum)
  512.  
  513. There are a couple of points to be aware of using the link edit
  514. commands.
  515.  
  516. Firstly, the commands are not executed in the order in which they
  517. are specified. All the commands for one file are performed
  518. together. They are also carried out in the order in which the
  519. files are specified on the command line. As the order in which
  520. library members will be read is not defined, the order in which
  521. link edit commands for these are executed is undefined as well.
  522.  
  523. There are times when the commands will appear not to work In a 'C'
  524. or DDE Pascal program, if a symbol reference, for example, a
  525. function call, is changed, references to that symbol within the
  526. AOF file will not be altered as the compiler will have resolved
  527. the references at compile time.
  528.  
  529.  
  530. A Brief Description of Drlink
  531. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  532. Drlink starts by reading the list of object files and libraries
  533. given on the command line into memory, except for any libraries
  534. given on the option '-lib'. Any 'link edit' commands are acted
  535. upon as the files are read. After this, Drlink attempts to resolve
  536. symbol references in each object file using, first, the symbols
  537. defined as being local to that file and then symbols defined as
  538. available to any file. If there are still any unresolved symbols,
  539. it then goes through each library trying to find them. The
  540. libraries are searched in the order they are specified on the
  541. command line, from left to right. This includes libraries
  542. specified on the '-lib' option. Each library is scanned only once,
  543. unless the option '-rescan' is used.  This means that any library
  544. members read can only refer to symbols that are already known or
  545. that can be found in that library or one that has yet to be
  546. searched. The order that libraries are specified on the command
  547. line is therefore very important. If, on the other hand, '-rescan'
  548. is specified, Drlink will keep searching the libraries until all
  549. the symbols have been found or until it determines that a symbol
  550. cannot be found in any library.
  551.  
  552. Assuming that all symbol references have been found, Drlink moves
  553. on to resolving addresses. Before it does that, however, if the
  554. '-nounused' option was specified, it attempts to determine the
  555. areas in the program that are not referenced from any other areas
  556. and removes any it finds from the program. Next, it determines the
  557. proper addresses of all the symbols and areas in the program and
  558. then goes through the program relocating and resolving addresses.
  559. If the '-debug' option is used, the low level debugging table is
  560. created at this point. The final step is to write the completed
  561. image file to disk.
  562.  
  563. Drlink has the ability to increase the amount of memory it is
  564. using if it is running in a task window or using the 'F12' CLI. It
  565. will acquire as much extra memory as it needs and return it once
  566. the link has completed. Drlink can be run in a wimpslot of only
  567. 64K bytes.
  568.  
  569.  
  570. Pre-defined Symbols
  571. ~~~~~~~~~~~~~~~~~~~
  572. There are a number of pre-defined symbols that can be referenced
  573. in object files. These are defined by the linker itself. The ones
  574. that Drlink supports are:
  575.  
  576. Image$$RO$$Base    The start address of the 'read-only' part of
  577.                    executable image when loaded into memory. This
  578.                    contains program code and constants.
  579.  
  580.  
  581. Image$$RO$$Limit   This is the address of the byte after the last
  582.                    byte of the 'read-only' part of a program when
  583.                    loaded into memory.
  584.  
  585. Image$$RW$$Base    This gives the address of the first byte of the
  586.                    'read/write' portion of a program when loaded
  587.                    into memory. This contains program code and
  588.                    data.
  589.  
  590. Image$$RW$$Limit   This defines the address of the byte after the
  591.                    last byte of the 'read/write' part of the
  592.                    program. The includes any zero-initialised data
  593.                    areas.
  594.  
  595. Image$$ZI$$Base    This symbol defines the start address of the
  596.                    'zero-initialised' part of the program when
  597.                    loaded into memory. This is simply an area of
  598.                    memory that is used by the program when it is
  599.                    run to hold data. It is not included in the
  600.                    image file on disk to prevent the image file
  601.                    becoming bloated with huge tracts of
  602.                    uninitialised data (except the Acorn C compiler
  603.                    does not make use of them and so the image
  604.                    file can become bloated with huge tracts of
  605.                    uninitialised data). When the program is run,
  606.                    the zero-initialised data area is cleared to
  607.                    zeros.
  608.  
  609. Image$$ZI$$Limit   This marks the address of the byte following
  610.                    the last byte of the 'zero-initialised' data
  611.                    part.
  612.  
  613.                    It should be noted that, with Drlink, the two
  614.                    symbols 'Image$$RW$$Limit' and 'Image$$ZILimit'
  615.                    are set to the same value.
  616.  
  617. The Acorn documentation says that the end of one part of the
  618. executable image should not be assumed to coincide with the start
  619. of the next, for example, it should not be assumed that the
  620. read/write part of the image starts the byte after the read-only
  621. part.
  622.  
  623. The six 'Image$$' symbols are defined in the 'link' documentation
  624. but there are a large number of other undocumented symbols, some
  625. of which are used by the libraries supplied with the C compiler
  626. (the C release 3 libraries, at least). Drlink implements a
  627. number of these but not the whole set, nor are the ones that are
  628. present guarenteed to remain there.
  629.  
  630. 'Area' Symbols
  631. Roughly speaking, the part of the AOF file that contains the
  632. actual code, data and debugging tables compiled from the original
  633. source file is broken down into a number of named 'areas', for
  634. example, the C compiler generates an area called 'C$$Code' for
  635. program code and one called 'C$$Data' for any data. These will be
  636. present in each AOF file included in the link and what Drlink
  637. (and 'link') does is to group all the areas with the same name
  638. together. What is not documented, though, is that each uniquely
  639. named area encountered by the linker results in creation of three
  640. symbols that can be can be (and are) referenced by any object
  641. file. These are the area name itself and a 'base' and 'limit' pair
  642. which point at the start address of the first area of that name
  643. when the program is loaded and the address of the byte after the
  644. last occurrence of that area, for example, the area 'C$$Code'
  645. would generate the symbols 'C$$Code', 'C$$Code$$Base' and
  646. 'C$$Code$$Limit'. The area 'C$$Debug' adds the symbols 'C$$Debug',
  647. 'C$$Debug$$Base' and 'C$$Debug$$Limit' to the linker's symbol
  648. table.
  649.  
  650. What was said in the preceding paragraph also applies to 'common'
  651. blocks. These are areas just like any other, but they are handled
  652. slightly differently in that all common block areas with the same
  653. name are overlaid on one another with the size of the common block
  654. being that of the largest instance of the common block. Just as
  655. with other areas, three symbols are created for each common block
  656. that can be used in programs: the common block name and a 'base'
  657. and 'limit' pair based on that name, for example, a common block
  658. called 'acorn' would add the symbols 'acorn', 'acorn$$Base' and
  659. 'acorn$$Limit' to the linker's tables.
  660.  
  661. If the '-zo' C compiler option is used, each function in the
  662. object code has its own uniquely-name area and this results in an
  663. explosion in the number of area symbols generated. Normally this
  664. would not be a problem except for the extra memory required to
  665. hold these symbols, but it results in the low-level debugging
  666. table created by the linker becoming flooded with what is, in the
  667. author's opinion, totally useless symbol information. Drlink's
  668. solution to this problem is not to include any symbols generated
  669. for areas apart from those for common blocks in the low-level
  670. debugging table.
  671.  
  672. There are other symbols that 'link' defines internally but these
  673. have not been seen in any AOF files yet and so they have not be
  674. included in Drlink.
  675.  
  676.  
  677. Differences Between Drlink and Link
  678. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  679. Drlink is based on the version of 'link' that comes with
  680. release 3 of the C compiler but there are a number of features of
  681. 'link' that are missing or that have been changed slightly. The
  682. idea is that Drlink will be used to link 'ordinary' programs and
  683. not any of the more exotic types that the Acorn linker can handle,
  684. for example, creating partially-linked AOF files.
  685.  
  686. First, the missing features:
  687.  
  688. 1)  It does not generate partially linked files (the '-aof'
  689.     option).
  690.  
  691. 2)  Drlink does not support overlays (the '-overlay' option).
  692.  
  693. 3)  The entry address of the program cannot be specified (the
  694.     option '-entry').
  695.  
  696. 4)  It is not possible to give the base address of a program (the
  697.     option '-base'. This will always be set to &8000.
  698.  
  699. 5)  The old debug option '-dbug' is not supported.
  700.  
  701. 6)  The option to print a list of cross references between areas
  702.     has not be included (option '-xref').
  703.  
  704. 7)  It does not support unnamed common blocks.
  705.  
  706. 8)  Drlink does not allow a common block and another symbol that
  707.     is defined as visible to any file to have the same name. A
  708.     'duplicate symbol' error will be flagged if this happens.
  709.  
  710. 9)  It does not support the 'strong' symbol attribute.
  711.  
  712. 10) The 'link' documentation contains vague references to Un*x
  713.     'Aout' format files. Drlink does not handle these.
  714.  
  715. The known differences are:
  716.  
  717. 1)  The low level debugging tables do not have as many entries in
  718.     them as the ones generated by 'link'.  'link' includes entries
  719.     for symbols for every single area in the executable program
  720.     but Drlink leaves out all of these apart from the ones for
  721.     'common' blocks.
  722.  
  723. 2)  There are a number of undocumented built-in linker symbols
  724.     available in 'link' such as '_esdata' that Drlink does not
  725.     include.
  726.  
  727. 3)  The default program name created by the linker is '!Runimage'
  728.     and not 'aif'.
  729.  
  730. 4)  If the '-bin' option is used to create a binary file and the
  731.     entry point is not the first instruction in the program,
  732.     Drlink adds a branch to that address at the start of the
  733.     program.
  734.  
  735. 5)  The link edit commands are different to link's.
  736.  
  737. The extensions to the Acorn release 3 link are:
  738.  
  739. 1)  If running under a task window or in the 'F12' CLI, Drlink can
  740.     extend its wimpslot.
  741.  
  742. 2)  It can removed unreferenced areas from the executable program.
  743.  
  744. 3)  Drlink supports extended command lines.
  745.  
  746. 4)  It can scan libraries more than once.
  747.  
  748. 5)  Debugging tables can be selectively included in the image
  749.     file.
  750.  
  751. In all other respects, Drlink should behave in exactly the same
  752. way as 'link', hopefully apart from some known bugs in 'link'.
  753. There are probably other subtle differences in the way the linkers
  754. behave but these are not known.
  755.  
  756.  
  757. Change Record
  758. ~~~~~~~~~~~~~
  759. Drlink 0.20 - First release version.
  760.  
  761. Drlink 0.21
  762. -  Added support for type-2 relocations.
  763. -  Fixed problem with paths with multiple directories in
  764.    filenames.
  765. -  Speeded up linker a bit.
  766.  
  767. Drlink 0.22
  768. -  Fixed bug where symbolic debug tables were left out of the
  769.    image file if '-nounused' was used.
  770. -  Changed way linker orders areas to more closely match that of
  771.    'link'.
  772. -  Added option '-keepdebug' to selectively include debugging
  773.    information from object files in image file.
  774. -  Allowed filenames supplied for options '-lib' and '-keepdebug'
  775.    to be enclosed in double quotes. This will, in fact, work on
  776.    any option.
  777.  
  778. Drlink 0.23
  779. -  Added 'link edit' commands (the '-edit' option).
  780. -  Added code to allow 'back-to-front' filenames.
  781. -  Now sets a return code of 12 if a link fails.
  782. -  Fixed bug in '-keepdebug' code where a buffer was overflowing
  783.    and overwriting anything that followed it, e.g. amu.
  784.  
  785. Drlink 0.24
  786. -  Made 'verbose' mode list the names of the external references
  787.    being satisfied and the files containing those references when
  788.    loading library members.
  789. -  It now prints a warning message about and lists files specified
  790.    on '-keepdebug' that were not loaded.
  791. -  A problem with extended command lines containing rubbish at the
  792.    end of the line has been fixed.
  793.  
  794.  
  795.  
  796. Future Developments
  797. ~~~~~~~~~~~~~~~~~~~
  798. The list of features to be added in the future is down to just one
  799. now:
  800.  
  801. -  The ability to generate a partially-linked AOF file.
  802.  
  803. This will appear soon, plus I would like to make Drlink run faster
  804. and improve the memory management. At the moment, if you have
  805. enough memory to link a program then fine, but if you don't, then
  806. tough. Any other suggestions people have will be gratefully
  807. received.
  808.  
  809. Thanks primarily to Simon Glass, Drlink has a lot more features
  810. than it was originally planned to have and I do not think it
  811. misses out anything vitally important now. It would be interesting
  812. to know if anyone uses the features of 'link' that have been left
  813. out of this version of Drlink. 
  814.  
  815. If anyone has any suggestions or comments on Drlink, I can be
  816. contacted on the Arcade Bulletin Board, user #418 'Davedan'.
  817. Telephone numbers for Arcade are 081-654-2212 and 081-655-4412.
  818. Sorry, I do not have access to Usenet, but some messages
  819. from the various Acorn newsgroups do make it as far as the
  820. Comp.Sys.Acorn Fidonet Echo and if they do, then I will see
  821. them although I cannot reply to them.
  822.  
  823.  
  824. Copyright
  825. ~~~~~~~~~
  826. The software and the documentation that goes with it is
  827. Copyright ⌐ David Daniels 1993. All Rights Reserved.
  828.  
  829. Permission is hereby given for you to copy this program and freely
  830. distribute it, subject to the following conditions:
  831.  
  832.  * No charge is made for the program (except nominal media costs).
  833.  * No alterations are made to any of the files within this archive file.
  834.  * All of the files within this archive are supplied, including this one.
  835.  * No part of this program is included in a commercial product.
  836.  
  837.